package com.ftg.learn.service;

import com.ftg.learn.dao.Danpin;
import com.ftg.learn.mapper.DanpinMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DanpinService {
    @Autowired
    DanpinMapper danpinMapper;
    //显示全部
    public List<Danpin> select(int page, int limit, String name){
        int begin=(page-1)*limit;
        name=("".equals(name)?null:name);
        return danpinMapper.select(begin,limit,name);
    }

    public List<Danpin> showall(){


        return danpinMapper.showall();
    }
    //查一
    public int getCount(String name){
        name=("".equals(name)?null:name);
        return  danpinMapper.geleteDanpin(name);
    }
    //添加
    public int add(Danpin danpin){
        return danpinMapper.add(danpin);
    }
    //删除
    public int delete(String id){
        return danpinMapper.delete(id);
    }
    //修改
    public int update(Danpin danpin){
        return danpinMapper.update(danpin);
    }

    public List<Danpin> selectpicture() {
        return danpinMapper.selectpicture();
    }
}
